<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-US">
<head>
<!-- GenHTML revision 25226-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>An Application Example That Consumes Messages from a Remote Server - The Java EE 6 Tutorial</title>
<meta name="robots" content="index,follow">
<meta name="robots" content="index,follow">
<meta name="date" content="2011-03-01">
<link rel="stylesheet" type="text/css" href="css/default.css">
<link rel="stylesheet" type="text/css" href="css/ipg.css">
<link rel="stylesheet" type="text/css" href="css/javaeetutorial.css">
</head>

<body>

<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tbody>
   <tr valign="top">
      <td width="400px"><p class="toc level1"><a href="docinfo.html">Document Information</a></p>
<p class="toc level1 tocsp"><a href="gexaf.html">Preface</a></p>
<p class="toc level1 tocsp"><a href="gfirp.html">Part&nbsp;I&nbsp;Introduction</a></p>
<p class="toc level2"><a href="bnaaw.html">1.&nbsp;&nbsp;Overview</a></p>
<p class="toc level2"><a href="gfiud.html">2.&nbsp;&nbsp;Using the Tutorial Examples</a></p>
<p class="toc level1 tocsp"><a href="bnadp.html">Part&nbsp;II&nbsp;The Web Tier</a></p>
<p class="toc level2"><a href="bnadr.html">3.&nbsp;&nbsp;Getting Started with Web Applications</a></p>
<p class="toc level2"><a href="bnaph.html">4.&nbsp;&nbsp;JavaServer Faces Technology</a></p>
<p class="toc level2"><a href="giepx.html">5.&nbsp;&nbsp;Introduction to Facelets</a></p>
<p class="toc level2"><a href="gjddd.html">6.&nbsp;&nbsp;Expression Language</a></p>
<p class="toc level2"><a href="bnaqz.html">7.&nbsp;&nbsp;Using JavaServer Faces Technology in Web Pages</a></p>
<p class="toc level2"><a href="gjcut.html">8.&nbsp;&nbsp;Using Converters, Listeners, and Validators</a></p>
<p class="toc level2"><a href="bnatx.html">9.&nbsp;&nbsp;Developing with JavaServer Faces Technology</a></p>
<p class="toc level2"><a href="gkmaa.html">10.&nbsp;&nbsp;JavaServer Faces Technology Advanced Concepts</a></p>
<p class="toc level2"><a href="bnawo.html">11.&nbsp;&nbsp;Configuring JavaServer Faces Applications</a></p>
<p class="toc level2"><a href="gkiow.html">12.&nbsp;&nbsp;Using Ajax with JavaServer Faces Technology</a></p>
<p class="toc level2"><a href="gkhxa.html">13.&nbsp;&nbsp;Advanced Composite Components</a></p>
<p class="toc level2"><a href="bnavg.html">14.&nbsp;&nbsp;Creating Custom UI Components</a></p>
<p class="toc level2"><a href="bnafd.html">15.&nbsp;&nbsp;Java Servlet Technology</a></p>
<p class="toc level2"><a href="bnaxu.html">16.&nbsp;&nbsp;Internationalizing and Localizing Web Applications</a></p>
<p class="toc level1 tocsp"><a href="bnayk.html">Part&nbsp;III&nbsp;Web Services</a></p>
<p class="toc level2"><a href="gijti.html">17.&nbsp;&nbsp;Introduction to Web Services</a></p>
<p class="toc level2"><a href="bnayl.html">18.&nbsp;&nbsp;Building Web Services with JAX-WS</a></p>
<p class="toc level2"><a href="giepu.html">19.&nbsp;&nbsp;Building RESTful Web Services with JAX-RS</a></p>
<p class="toc level2"><a href="gjjxe.html">20.&nbsp;&nbsp;Advanced JAX-RS Features</a></p>
<p class="toc level2"><a href="gkojl.html">21.&nbsp;&nbsp;Running the Advanced JAX-RS Example Application</a></p>
<p class="toc level1 tocsp"><a href="bnblr.html">Part&nbsp;IV&nbsp;Enterprise Beans</a></p>
<p class="toc level2"><a href="gijsz.html">22.&nbsp;&nbsp;Enterprise Beans</a></p>
<p class="toc level2"><a href="gijre.html">23.&nbsp;&nbsp;Getting Started with Enterprise Beans</a></p>
<p class="toc level2"><a href="gijrb.html">24.&nbsp;&nbsp;Running the Enterprise Bean Examples</a></p>
<p class="toc level2"><a href="bnbpk.html">25.&nbsp;&nbsp;A Message-Driven Bean Example</a></p>
<p class="toc level2"><a href="gkcqz.html">26.&nbsp;&nbsp;Using the Embedded Enterprise Bean Container</a></p>
<p class="toc level2"><a href="gkidz.html">27.&nbsp;&nbsp;Using Asynchronous Method Invocation in Session Beans</a></p>
<p class="toc level1 tocsp"><a href="gjbnr.html">Part&nbsp;V&nbsp;Contexts and Dependency Injection for the Java EE Platform</a></p>
<p class="toc level2"><a href="giwhb.html">28.&nbsp;&nbsp;Introduction to Contexts and Dependency Injection for the Java EE Platform</a></p>
<p class="toc level2"><a href="gjbls.html">29.&nbsp;&nbsp;Running the Basic Contexts and Dependency Injection Examples</a></p>
<p class="toc level2"><a href="gjehi.html">30.&nbsp;&nbsp;Contexts and Dependency Injection for the Java EE Platform: Advanced Topics</a></p>
<p class="toc level2"><a href="gkhre.html">31.&nbsp;&nbsp;Running the Advanced Contexts and Dependency Injection Examples</a></p>
<p class="toc level1 tocsp"><a href="bnbpy.html">Part&nbsp;VI&nbsp;Persistence</a></p>
<p class="toc level2"><a href="bnbpz.html">32.&nbsp;&nbsp;Introduction to the Java Persistence API</a></p>
<p class="toc level2"><a href="gijst.html">33.&nbsp;&nbsp;Running the Persistence Examples</a></p>
<p class="toc level2"><a href="bnbtg.html">34.&nbsp;&nbsp;The Java Persistence Query Language</a></p>
<p class="toc level2"><a href="gjitv.html">35.&nbsp;&nbsp;Using the Criteria API to Create Queries</a></p>
<p class="toc level2"><a href="gkjiq.html">36.&nbsp;&nbsp;Creating and Using String-Based Criteria Queries</a></p>
<p class="toc level2"><a href="gkjjf.html">37.&nbsp;&nbsp;Controlling Concurrent Access to Entity Data with Locking</a></p>
<p class="toc level2"><a href="gkjia.html">38.&nbsp;&nbsp;Improving the Performance of Java Persistence API Applications By Setting a Second-Level Cache</a></p>
<p class="toc level1 tocsp"><a href="gijrp.html">Part&nbsp;VII&nbsp;Security</a></p>
<p class="toc level2"><a href="bnbwj.html">39.&nbsp;&nbsp;Introduction to Security in the Java EE Platform</a></p>
<p class="toc level2"><a href="bncas.html">40.&nbsp;&nbsp;Getting Started Securing Web Applications</a></p>
<p class="toc level2"><a href="bnbyk.html">41.&nbsp;&nbsp;Getting Started Securing Enterprise Applications</a></p>
<p class="toc level1 tocsp"><a href="gijue.html">Part&nbsp;VIII&nbsp;Java EE Supporting Technologies</a></p>
<p class="toc level2"><a href="gijto.html">42.&nbsp;&nbsp;Introduction to Java EE Supporting Technologies</a></p>
<p class="toc level2"><a href="bncih.html">43.&nbsp;&nbsp;Transactions</a></p>
<p class="toc level2"><a href="bncjh.html">44.&nbsp;&nbsp;Resource Connections</a></p>
<p class="toc level2"><a href="bncdq.html">45.&nbsp;&nbsp;Java Message Service Concepts</a></p>
<p class="toc level2"><a href="bncgv.html">46.&nbsp;&nbsp;Java Message Service Examples</a></p>
<p class="toc level3"><a href="bncfa.html">Writing Simple JMS Applications</a></p>
<p class="toc level4"><a href="bncfa.html#bncfb">A Simple Example of Synchronous Message Receives</a></p>
<p class="toc level5"><a href="bncfa.html#bncfc">Writing the Clients for the Synchronous Receive Example</a></p>
<p class="toc level5"><a href="bncfa.html#bncfd">Starting the JMS Provider</a></p>
<p class="toc level5"><a href="bncfa.html#gktjs">JMS Administered Objects for the Synchronous Receive Example</a></p>
<p class="toc level5"><a href="bncfa.html#bncfg">Building, Packaging, Deploying, and Running the Clients for the Synchronous Receive Example</a></p>
<p class="toc level4 tocsp"><a href="bncfa.html#bncfh">A Simple Example of Asynchronous Message Consumption</a></p>
<p class="toc level5"><a href="bncfa.html#bncfi">Writing the Clients for the Asynchronous Receive Example</a></p>
<p class="toc level5"><a href="bncfa.html#gjsch">To Build and Package the <tt>AsynchConsumer</tt> Client  Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bncfa.html#gjscf">To Deploy and Run the Clients for the Asynchronous Receive Example Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bncfa.html#bncfj">To Build and Package the <tt>AsynchConsumer</tt> Client Using Ant</a></p>
<p class="toc level5"><a href="bncfa.html#bncfk">To Deploy and Run the Clients for the Asynchronous Receive Example Using Ant and the <tt>appclient</tt> Command</a></p>
<p class="toc level4 tocsp"><a href="bncfa.html#bncfl">A Simple Example of Browsing Messages in a Queue</a></p>
<p class="toc level5"><a href="bncfa.html#bncfm">Writing the Client for the Queue Browser Example</a></p>
<p class="toc level5"><a href="bncfa.html#bncfo">To Build, Package, Deploy, and Run the <tt>MessageBrowser</tt> Client Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bncfa.html#bncfn">To Build, Package, Deploy, and Run the <tt>MessageBrowser</tt> Client Using Ant and the <tt>appclient</tt> Command</a></p>
<p class="toc level4 tocsp"><a href="bncfa.html#bncfp">Running JMS Clients on Multiple Systems</a></p>
<p class="toc level5"><a href="bncfa.html#bncfq">To Create Administered Objects for Multiple Systems</a></p>
<p class="toc level5"><a href="bncfa.html#gjsdi">Changing the Default Host Name</a></p>
<p class="toc level5"><a href="bncfa.html#gjsag">To Edit, Build, Package, Deploy, and Run the Clients Using NetBeans IDE</a></p>
<p class="toc level5"><a href="bncfa.html#bncfs">To Edit, Build, Package, Deploy, and Run the Clients Using Ant and the <tt>appclient</tt> Command</a></p>
<p class="toc level4 tocsp"><a href="bncfa.html#bncft">Undeploying and Cleaning the Simple JMS Examples</a></p>
<p class="toc level3 tocsp"><a href="giwfh.html">Writing Robust JMS Applications</a></p>
<p class="toc level4"><a href="giwfh.html#bncfx">A Message Acknowledgment Example</a></p>
<p class="toc level5"><a href="giwfh.html#gjsab">To Build, Package, Deploy, and Run the <tt>ackequivexample</tt> Using NetBeans IDE</a></p>
<p class="toc level5"><a href="giwfh.html#gjscg">To Build, Package, Deploy, and Run <tt>ackequivexample</tt> Using Ant</a></p>
<p class="toc level4 tocsp"><a href="giwfh.html#bncgg">A Durable Subscription Example</a></p>
<p class="toc level5"><a href="giwfh.html#gjsar">To Build, Package, Deploy, and Run <tt>durablesubscriberexample</tt> Using NetBeans IDE</a></p>
<p class="toc level5"><a href="giwfh.html#gjsci">To Build, Package, Deploy, and Run <tt>durablesubscriberexample</tt> Using Ant</a></p>
<p class="toc level4 tocsp"><a href="giwfh.html#bncgj">A Local Transaction Example</a></p>
<p class="toc level5"><a href="giwfh.html#gjsem">To Build, Package, Deploy, and Run <tt>transactedexample</tt> Using NetBeans IDE</a></p>
<p class="toc level5"><a href="giwfh.html#gjsha">To Build, Package, Deploy, and Run <tt>transactedexample</tt> Using Ant and the <tt>appclient</tt> Command</a></p>
<p class="toc level3 tocsp"><a href="bncgw.html">An Application That Uses the JMS API with a Session Bean</a></p>
<p class="toc level4"><a href="bncgw.html#bncgx">Writing the Application Components for the <tt>clientsessionmdb</tt> Example</a></p>
<p class="toc level5"><a href="bncgw.html#bncgz">Coding the Application Client: <tt>MyAppClient.java</tt></a></p>
<p class="toc level5"><a href="bncgw.html#bncha">Coding the Publisher Session Bean</a></p>
<p class="toc level5"><a href="bncgw.html#bnchb">Coding the Message-Driven Bean: <tt>MessageBean.java</tt></a></p>
<p class="toc level4 tocsp"><a href="bncgw.html#bnchc">Creating Resources for the <tt>clientsessionmdb</tt> Example</a></p>
<p class="toc level4"><a href="bncgw.html#bnchd">To Build, Package, Deploy, and Run the <tt>clientsessionmdb</tt> Example Using NetBeans IDE</a></p>
<p class="toc level4"><a href="bncgw.html#bnche">To Build, Package, Deploy, and Run the <tt>clientsessionmdb</tt> Example Using Ant</a></p>
<p class="toc level3 tocsp"><a href="bnchf.html">An Application That Uses the JMS API with an Entity</a></p>
<p class="toc level4"><a href="bnchf.html#bnchg">Overview of the <tt>clientmdbentity</tt> Example Application</a></p>
<p class="toc level4"><a href="bnchf.html#bnchi">Writing the Application Components for the <tt>clientmdbentity</tt> Example</a></p>
<p class="toc level5"><a href="bnchf.html#bnchj">Coding the Application Client: <tt>HumanResourceClient.java</tt></a></p>
<p class="toc level5"><a href="bnchf.html#bnchk">Coding the Message-Driven Beans for the <tt>clientmdbentity</tt> Example</a></p>
<p class="toc level5"><a href="bnchf.html#bnchl">Coding the Entity Class for the <tt>clientmdbentity</tt> Example</a></p>
<p class="toc level4 tocsp"><a href="bnchf.html#bnchm">Creating Resources for the <tt>clientmdbentity</tt> Example</a></p>
<p class="toc level4"><a href="bnchf.html#bnchn">To Build, Package, Deploy, and Run the <tt>clientmdbentity</tt> Example Using NetBeans IDE</a></p>
<p class="toc level4"><a href="bnchf.html#bncho">To Build, Package, Deploy, and Run the <tt>clientmdbentity</tt> Example Using Ant</a></p>
<div id="scrolltoc" class="onpage">
<p class="toc level3 tocsp"><a href="">An Application Example That Consumes Messages from a Remote Server</a></p>
<p class="toc level4"><a href="#bnchq">Overview of the <tt>consumeremote</tt> Example Modules</a></p>
<p class="toc level4"><a href="#bnchs">Writing the Module Components for the <tt>consumeremote</tt> Example</a></p>
<p class="toc level4"><a href="#bncht">Creating Resources for the <tt>consumeremote</tt> Example</a></p>
<p class="toc level4"><a href="#bnchu">Using Two Application Servers for the <tt>consumeremote</tt> Example</a></p>
<p class="toc level4"><a href="#bnchv">To Build, Package, Deploy, and Run the <tt>consumeremote</tt>Modules Using NetBeans IDE</a></p>
<p class="toc level4"><a href="#bnchw">To Build, Package, Deploy, and Run the <tt>consumeremote</tt> Modules Using Ant</a></p>
</div>
<p class="toc level3 tocsp"><a href="bnchx.html">An Application Example That Deploys a Message-Driven Bean on Two Servers</a></p>
<p class="toc level4"><a href="bnchx.html#bnchy">Overview of the <tt>sendremote</tt> Example Modules</a></p>
<p class="toc level4"><a href="bnchx.html#bnchz">Writing the Module Components for the <tt>sendremote</tt> Example</a></p>
<p class="toc level5"><a href="bnchx.html#bncib">Coding the Application Client: <tt>MultiAppServerClient.java</tt></a></p>
<p class="toc level5"><a href="bnchx.html#bncic">Coding the Message-Driven Bean: <tt>ReplyMsgBean.java</tt></a></p>
<p class="toc level4 tocsp"><a href="bnchx.html#bncid">Creating Resources for the <tt>sendremote</tt> Example</a></p>
<p class="toc level4"><a href="bnchx.html#gkpbq">To Enable Deployment on the Remote System</a></p>
<p class="toc level4"><a href="bnchx.html#bncie">To Use Two Application Servers for the <tt>sendremote</tt> Example</a></p>
<p class="toc level4"><a href="bnchx.html#bncif">To Build, Package, Deploy, and Run the <tt>sendremote</tt> Modules Using NetBeans IDE</a></p>
<p class="toc level4"><a href="bnchx.html#bncig">To Build, Package, Deploy, and Run the <tt>sendremote</tt> Modules Using Ant</a></p>
<p class="toc level2 tocsp"><a href="gkahp.html">47.&nbsp;&nbsp;Advanced Bean Validation Concepts and Examples</a></p>
<p class="toc level2"><a href="gkeed.html">48.&nbsp;&nbsp;Using Java EE Interceptors</a></p>
<p class="toc level1 tocsp"><a href="gkgjw.html">Part&nbsp;IX&nbsp;Case Studies</a></p>
<p class="toc level2"><a href="gkaee.html">49.&nbsp;&nbsp;Duke's Tutoring Case Study Example</a></p>
<p class="toc level1 tocsp"><a href="idx-1.html">Index</a></p>
</td>
      <td width="10px">&nbsp;</td>
      <td>
         <div class="header">
             <div class="banner">
                <table width="100%" border="0" cellpadding="5" cellspacing="0">
                   <tbody>
                      <tr>
                         <td valign="bottom"><p class="Banner">The Java EE 6 Tutorial
</p></td>
                         <td align="right"  valign="bottom"><img src="graphics/javalogo.png" alt="Java Coffee Cup logo"></td>
                      </tr>
                   </tbody>
                </table>
             </div>

             <div class="header-links">
	         <a href="./index.html">Home</a> | 
<a href="../information/download.html">Download</a> | 
<a href="./javaeetutorial6.pdf">PDF</a> | 
<a href="../information/faq.html">FAQ</a> | 
<a href="http://download.oracle.com/javaee/feedback.htm">Feedback</a>

             </div>
             <div class="navigation">
                 <a href="bnchf.html"><img src="graphics/leftButton.gif" border="0" alt="Previous" title="Previous"></a>
                 <a href="p1.html"><img src="graphics/upButton.gif" border="0" alt="Contents" title="Contents"></a>
                 <a href="bnchx.html"><img src="graphics/rightButton.gif" border="0" alt="Next" title="Next"></a>
             </div>
         </div>

	 <div class="maincontent">      	 
             

<a name="bnchp"></a><h2>An Application Example That Consumes Messages from a Remote Server</h2>
<a name="indexterm-2509"></a><a name="indexterm-2510"></a><a name="indexterm-2511"></a><a name="indexterm-2512"></a><p>This section and the following section explain how to write, compile, package, deploy,
and run a pair of Java EE modules that run on two
Java EE servers and that use the JMS API to interchange messages with
each other. It is a common practice to deploy different components of an
enterprise application on different systems within a company, and these examples illustrate on
a small scale how to do this for an application that uses the
JMS API.</p>

<p>However, the two examples work in slightly different ways. In this first example,
the deployment information for a message-driven bean specifies the remote server from which
it will <b>consume</b> messages. In the next example, the same message-driven bean is
deployed on two different servers, so it is the client module that specifies
the servers (one local, one remote) to which it is <b>sending</b> messages.</p>

<p>This first example divides the example in <a href="bnbpk.html">Chapter&nbsp;25, A Message-Driven Bean Example</a> into two modules: one
containing the application client, and the other containing the message-driven bean.</p>

<p>You will find the source files for this section in <tt></tt><i>tut-install</i><tt>/examples/jms/consumeremote/</tt>. Path
names in this section are relative to this directory.</p>



<a name="bnchq"></a><h3>Overview of the <tt>consumeremote</tt> Example Modules</h3>
<p>Except for the fact that it is packaged as two separate modules,
this example is very similar to the one in <a href="bnbpk.html">Chapter&nbsp;25, A Message-Driven Bean Example</a>:</p>


<ul><li><p>One module contains the application client, which runs on the remote system and sends three messages to a queue.</p>

</li>
<li><p>The other module contains the message-driven bean, which is deployed on the local server and consumes the messages from the queue on the remote server.</p>

</li></ul>
<p>The basic steps of the modules are as follows.</p>


<ol><li><p>The administrator starts two Java EE servers, one on each system.</p>

</li>
<li><p>On the local server, the administrator deploys the message-driven bean module, which specifies the remote server where the client is deployed.</p>

</li>
<li><p>On the remote server, the administrator places the client JAR file.</p>

</li>
<li><p>The client module sends three messages to a queue.</p>

</li>
<li><p>The message-driven bean consumes the messages.</p>

</li></ol>
<p><a href="#bnchr">Figure&nbsp;46-5</a> illustrates the structure of this application. You can see that it is
almost identical to <a href="bnbpl.html#bnbpm">Figure&nbsp;25-1</a> except that there are two Java EE servers. The queue
used is the one on the remote server; the queue must also exist
on the local server for resource injection to succeed.</p>

<a name="bnchr"></a><p class="caption">Figure&nbsp;46-5 A Java EE Application That Consumes Messages from a Remote Server</p><img src="figures/jmsj2ee-consumeRemote.gif" alt="Diagram of application showing a message-driven bean that consumes messages from an application client on a remote server"></img>

<a name="bnchs"></a><h3>Writing the Module Components for the <tt>consumeremote</tt> Example</h3>
<p>Writing the components of the modules involves</p>


<ul><li><p>Coding the application client</p>

</li>
<li><p>Coding the message-driven bean</p>

</li></ul>
<p>The application client, <tt>jupiterclient/src/java/SimpleClient.java</tt>, is almost identical to the one in <a href="bnbpn.html">The <tt>simplemessage</tt> Application Client</a>.</p>

<p>Similarly, the message-driven bean, <tt>earthmdb/src/java/MessageBean.java</tt>, is almost identical to the one in
<a href="bnbpo.html">The Message-Driven Bean Class</a>. The only significant difference is that the activation config properties include one
property that specifies the name of the remote system. You need to edit
the source file to specify the name of your system.</p>



<a name="bncht"></a><h3>Creating Resources for the <tt>consumeremote</tt> Example</h3>
<p>The application client can use any connection factory that exists on the remote
server; it uses <tt>jms/ConnectionFactory</tt>. Both components use the queue named <tt>jms/Queue</tt>, which you
created for <a href="bncfa.html#bncfb">A Simple Example of Synchronous Message Receives</a>. The message-driven bean does not need a previously created connection factory; the
resource adapter creates one for it.</p>

<p>Any missing resources will be created when you deploy the example.</p>



<a name="bnchu"></a><h3>Using Two Application Servers for the <tt>consumeremote</tt> Example</h3>
<p>As in <a href="bncfa.html#bncfp">Running JMS Clients on Multiple Systems</a>, the two servers are referred to as <tt>earth</tt> and <tt>jupiter</tt>.</p>

<p>The GlassFish Server must be running on both systems.</p>

<p>Before you can run the example, you must change the default name
of the JMS host on <tt>jupiter</tt>, as described in <a href="bncfa.html#gjkpv">To Change the Default Host Name Using the Administration Console</a>. If you have
already performed this task, you do not have to repeat it.</p>

<p>Which system you use to package and deploy the modules and which
system you use to run the client depend on your network configuration (which
file system you can access remotely). These instructions assume that you can access the
file system of <tt>jupiter</tt> from <tt>earth</tt> but cannot access the file system of
<tt>earth</tt> from <tt>jupiter</tt>. (You can use the same systems for <tt>jupiter</tt> and <tt>earth</tt>
that you used in <a href="bncfa.html#bncfp">Running JMS Clients on Multiple Systems</a>.)</p>

<p>You can package both modules on <tt>earth</tt> and deploy the message-driven bean there.
The only action you perform on <tt>jupiter</tt> is running the client module.</p>



<a name="bnchv"></a><h3>To Build, Package, Deploy, and Run the <tt>consumeremote</tt>Modules Using NetBeans IDE</h3><p>To edit the message-driven bean source file and then package, deploy, and run
the modules using NetBeans IDE, follow these steps.</p>

<ol>
<li><b>From the File menu, choose Open Project.</b></li>
<li><b>In the Open Project dialog, navigate to:</b><pre><tt></tt><i>tut-install</i><tt>/examples/jms/consumeremote/</tt></pre></li>
<li><b>Select the <tt>earthmdb</tt> folder.</b></li>
<li><b>Select the Open as Main Project check box.</b></li>
<li><b>Click Open Project.</b></li>
<li><b>Edit the <tt>MessageBean.java</tt> file as follows:</b><ol style="list-style-type: lower-alpha">
<li><b>In the Projects tab, expand the <tt>earthmdb</tt>, Source Packages, and <tt>mdb</tt> nodes, then
double-click <tt>MessageBean.java</tt>.</b></li>
<li><b>Find the following line within the <tt>@MessageDriven</tt> annotation:</b><pre>        @ActivationConfigProperty(propertyName = "addressList",
            propertyValue = "remotesystem"),</pre></li>
<li><b>Replace <tt>remotesystem</tt> with the name of your remote system.</b></li></ol></li>
<li><b>Right-click the <tt>earthmdb</tt> project and select Build.</b><p>This command creates a JAR file that contains the bean class file.</p></li>
<li><b>From the File menu, choose Open Project.</b></li>
<li><b>Select the <tt>jupiterclient</tt> folder.</b></li>
<li><b>Select the Open as Main Project check box.</b></li>
<li><b>Click Open Project.</b></li>
<li><b>In the Projects tab, right-click the <tt>jupiterclient</tt> project and select Build.</b><p>This target creates a JAR file that contains the client class file and
a manifest file.</p></li>
<li><b>Right-click the <tt>earthmdb</tt> project and select Deploy.</b></li>
<li><b>To copy the <tt>jupiterclient</tt> module to the remote system, follow these steps:</b><ol style="list-style-type: lower-alpha">
<li><b>Change to the directory <tt>jupiterclient/dist</tt>:</b><pre><tt><b>cd ../jupiterclient/dist</b></tt></pre></li>
<li><b>Type a command like the following:</b><pre><tt><b>cp jupiterclient.jar F:/</b></tt></pre><p>That is, copy the client JAR file to a location on the
remote filesystem. You can use the file system graphical user interface on your
system instead of the command line.</p></li></ol></li>
<li><b>To run the application client, follow these steps:</b><ol style="list-style-type: lower-alpha">
<li><b>If you did not previously create the queue and connection factory on the
remote system (<tt>jupiter</tt>), go to <tt></tt><i>tut-install</i><tt>/examples/jms/consumeremote/jupiterclient</tt> on the remote system and type
the following command:</b><pre><tt><b>ant add-resources</b></tt></pre></li>
<li><b>Go to the directory on the remote system (<tt>jupiter</tt>) where you copied the
client JAR file.</b></li>
<li><b>To deploy the client module and retrieve the client stubs, use the following
command:</b><pre><tt><b>asadmin deploy --retrieve . jupiterclient.jar</b></tt></pre><p>This command deploys the client JAR file and retrieves the client stubs in
a file named <tt>jupiterclientClient.jar</tt></p></li>
<li><b>To run the client, use the following command:</b><pre><tt><b>appclient -client jupiterclientClient.jar</b></tt></pre><p>On <tt>jupiter</tt>, the output of the <tt>appclient</tt> command looks like this (preceded by
application client container output):</p><pre>Sending message: This is message 1 from jupiterclient
Sending message: This is message 2 from jupiterclient
Sending message: This is message 3 from jupiterclient</pre><p>On <tt>earth</tt>, the output in the server log looks something like this (preceded
by logging information):</p><pre>MESSAGE BEAN: Message received: This is message 1 from jupiterclient
MESSAGE BEAN: Message received: This is message 2 from jupiterclient
MESSAGE BEAN: Message received: This is message 3 from jupiterclient</pre></li></ol></li></ol>

<a name="bnchw"></a><h3>To Build, Package, Deploy, and Run the <tt>consumeremote</tt> Modules Using Ant</h3><p>To edit the message-driven bean source file and then package, deploy, and run
the modules using Ant, follow these steps.</p>

<ol>
<li><b>Open the file <tt></tt><i>tut-install</i><tt>/examples/jms/consumeremote/earthmdb/src/java/mdb/MessageBean.java</tt> in an editor.</b></li>
<li><b>Find the following line within the <tt>@MessageDriven</tt> annotation:</b><pre>        @ActivationConfigProperty(propertyName = "addressList",
            propertyValue = "remotesystem"),</pre></li>
<li><b>Replace <tt>remotesystem</tt> with the name of your remote system, then save and close
the file.</b></li>
<li><b>Go to the following directory:</b><pre><tt></tt><i>tut-install</i><tt>/examples/jms/consumeremote/earthmdb/</tt></pre></li>
<li><b>Type the following command:</b><pre><tt><b>ant</b></tt></pre><p>This command creates a JAR file that contains the bean class file.</p></li>
<li><b>Type the following command:</b><pre><tt><b>ant deploy</b></tt></pre></li>
<li><b>Go to the <tt>jupiterclient</tt> directory:</b><pre><tt><b>cd ../jupiterclient</b></tt></pre></li>
<li><b>Type the following command:</b><pre><tt><b>ant</b></tt></pre><p>This target creates a JAR file that contains the client class file
and a manifest file.</p></li>
<li><b>To copy the <tt>jupiterclient</tt> module to the remote system, follow these steps:</b><ol style="list-style-type: lower-alpha">
<li><b>Change to the directory <tt>jupiterclient/dist</tt>:</b><pre><tt><b>cd ../jupiterclient/dist</b></tt></pre></li>
<li><b>Type a command like the following:</b><pre><tt><b>cp jupiterclient.jar F:/</b></tt></pre><p>That is, copy the client JAR file to a location on the
remote filesystem.</p></li></ol></li>
<li><b>To run the application client, follow these steps:</b><ol style="list-style-type: lower-alpha">
<li><b>If you did not previously create the queue and connection factory on the
remote system (<tt>jupiter</tt>), go to <tt></tt><i>tut-install</i><tt>/examples/jms/consumeremote/jupiterclient</tt> on the remote system and type
the following command:</b><pre><tt><b>ant add-resources</b></tt></pre></li>
<li><b>Go to the directory on the remote system (<tt>jupiter</tt>) where you copied the
client JAR file.</b></li>
<li><b>To deploy the client module and retrieve the client stubs, use the following
command:</b><pre><tt><b>asadmin deploy --retrieve . jupiterclient.jar</b></tt></pre><p>This command deploys the client JAR file and retrieves the client stubs in
a file named <tt>jupiterclientClient.jar</tt></p></li>
<li><b>To run the client, use the following command:</b><pre><tt><b>appclient -client jupiterclientClient.jar</b></tt></pre><p>On <tt>jupiter</tt>, the output of the <tt>appclient</tt> command looks like this (preceded by
application client container output):</p><pre>Sending message: This is message 1 from jupiterclient
Sending message: This is message 2 from jupiterclient
Sending message: This is message 3 from jupiterclient</pre><p>On <tt>earth</tt>, the output in the server log looks something like this (preceded
by logging information):</p><pre>MESSAGE BEAN: Message received: This is message 1 from jupiterclient
MESSAGE BEAN: Message received: This is message 2 from jupiterclient
MESSAGE BEAN: Message received: This is message 3 from jupiterclient</pre></li></ol></li></ol>
         </div>
         <div class="navigation">
             <a href="bnchf.html"><img src="graphics/leftButton.gif" border="0" alt="Previous" title="Previous"></a>
             <a href="p1.html"><img src="graphics/upButton.gif" border="0" alt="Contents" title="Contents"></a>
             <a href="bnchx.html"><img src="graphics/rightButton.gif" border="0" alt="Next" title="Next"></a>
         </div>

         <div class="copyright">
      	    <p>Copyright &copy; 2011, Oracle and/or its affiliates. All rights reserved. <a href="docinfo.html">Legal Notices</a></p>
      	 </div>

      </td>
   </tr>
</tbody>
</table>
</body>
</html>

